<?php

namespace app\common\model\user;

use think\Model;

class Real extends Model
{
    // 表名
    protected $name = 'user_real';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [

    ];

    /**
     * 添加 or 更新 数据
     */
    public  function add_or_up($data,$condition=null){
        if (!is_array($data)){
            renderJson('传递参数不合法', 0);
        }
        //新增
        if(empty($condition)){
            $this->allowField(true)->save($data);
        }
        //更新
        else{
            $this->allowField(true)->save($data,$condition);
        }
        return $this->toArray();
    }


    public function user(){
        return $this->hasOne("app\common\model\User","uid","uid");
    }

    public function userAttribute(){
        return $this->hasOne("app\common\model\user\Attribute","uid","uid");
    }

    public function authReal(){
        return $this->hasOne("app\common\model\auth\Real","uid","uid");
    }

    







}
